package com.tim.app.server.api;

import android.text.TextUtils;

import com.application.library.net.ResponseCallback;
import com.lzy.okhttputils.cache.CacheMode;
import com.tim.app.RT;
import com.tim.app.constant.AppKey;
import com.tim.app.server.logic.UserManager;
import com.tim.app.server.net.HttpMethod;
import com.tim.app.server.net.NetworkInterface;

import java.util.HashMap;

/**
 * 初始化
 */
public class API_Found {

    private static volatile API_Found api = null;
    private static String API_FOUND_SCHEME = "";

    public static final String GET_DYNAMIC_DETAIL_INFO = "/moli_explore_consumer/v1/publish/selectByPrimaryKey";//动态详情

    public static final String GET_ARTICLE_DETAIL_INFO = "/moli_explore_consumer/publish/v1.1/selectByPrimaryPublishKeyV1Dot1";//文章详情

    public static final String GET_COMMENT_LIST = "/moli_explore_consumer/v1/comment/selectPageByType";//评论列表API

    public static final String ADD_COMMENT = "/moli_explore_consumer/v1/comment/insertSelective";//发表评论

    public static final String GET_PROBLEM_DETAIL = "/moli_explore_consumer//problem/v1.1/selectByPrimaryKeyProblemV1Dot1";//获取问题详情

    public static final String GET_ANSWER_DETAIL = "/moli_explore_consumer/answer/v1.1/selectByPrimaryKeyAnswer";//获取回答详情

    public static final String GET_ANSWER_LIST = "/moli_explore_consumer/v1/answer/selectPageByProblemId";//获取回答列表

    public static final String GET_TOPIC_DEITAL = "/moli_explore_consumer/v1/topic/selectByPrimaryKey";//话题详情

    public static final String GET_STORY_DEITAL = "/moli_explore_consumer/v1/story/selectByPrimaryKey";//故事详情

    public static final String GET_RELATE_TOPIC = "/moli_explore_consumer/v1/topic/selectAllByPidTopic";//查看相关话题

    private static final String GET_PROBLEM_LIST = "/moli_explore_consumer/v1/problem/selectPageByTopicId";//问题列表接口

    private static final String GET_SOMEONE_PROBLEM_LIST = "/moli_explore_consumer/problem/v1.3.0/selectMyProblem";//获取某人的问题列表

    private static final String GET_PROBLEM_DATA_LIST = "/moli_explore_consumer/problem/v1.3.0/selectNewHotProblem";//获取新的问题列表接口

    private static final String GET_NEW_PROBLEM_LIST = "/moli_explore_consumer/problem/v1.1/selectProblemNewestListByTopicIdV1Dot1";//话题详情页最新接口

    private static final String GET_HOT_PROBLEM_LIST = "/moli_explore_consumer/answer/v1.1/selectAnswerisHotListByTopicIdV1Dot1";//话题详情页最热接口

    private static final String PUBLISH_PROBLEM = "/moli_explore_consumer/v1/problem/insertSelective";//发布问题

    private static final String PUBLISH_ANSWER = "/moli_explore_consumer/v1/answer/insertSelective";//发布回答

    private static final String GET_ARTICLE_LIST = "/moli_explore_consumer/v1/publish/selectageBySortPublish";//获取文章/动态列表

    private static final String GET_STORY_LIST = "/moli_explore_consumer/v1/story/selectPageByTopicId";//获取故事列表

    private static final String GET_ADVERTISEMENT_LIST = "/moli_discover_consumer/v1/advertisement/selectAllAdvertisement";//获取广告列表

    private static final String GET_DYNAMIC_LIST = "/moli_discover_consumer/v1/dynamic/selectDynamic";//获取动态列表

    private static final String GET_SPEAK_LIST = "/moli_explore_consumer/v1/publish/selectDynamicByUserId";//获取动态列表

    private static final String POST_DYNAMIC = "/moli_explore_consumer/v1/publish/insertSelective";//发布动态

    private static final String GET_MY_ARTICLE = "/moli_explore_consumer/v1/publish/selectByUserIdPublish";//获取我的文章

    private static final String GET_RECOMMAND_TOPIC = "/moli_explore_consumer/v1/topic/selectPageByTopic";//推荐话题

    private static final String GET_RECOMMAND_TOPIC_FOR_ASK_QUESTION = "/moli_explore_consumer/v1/topic/selectAllTopicByPage";//推荐话题-提问

    private static final String MODTIFY_ANSWER = "/moli_explore_consumer/v1/answer/updateByPrimaryKeySelective";//修改回答

    private static final String DELETE_ANSWER = "/moli_explore_consumer/v1/answer/updateByPrimaryKeySelective";//删除回答

    private static final String DELETE_PUBLISH = "/moli_explore_consumer/v1/publish/updateByPrimaryKeySelective";//删除发表

    private static final String DELETE_STORY = "/moli_explore_consumer/v1/story/updateByPrimaryKeySelective";//删除故事

    private static final String GET_COMMENT_DETAIL = "/moli_explore_consumer/v1/comment/selectByPrimaryKey";//评论详情

    private static final String GET_OFFIAIA_PUSH = "/moli_discover_consumer/v1/officialpush/selectAllPushInfoByPage";//获取官方推送

    private static final String GET_NEXT_ANSWER = "/moli_explore_consumer/v1/answer/selectPageByProblemId";//下一个回答

    private static final String ADD_REPLY = "/moli_explore_consumer/reply/v1/insertSelective";//添加回复

    private static final String DELETE_REPLY = "/moli_explore_consumer/reply/v1/updateByPrimaryKeyDeleted";//删除回复

    private static final String GET_REPLY_COMMENT = "/moli_explore_consumer/reply/v1/selectAllReplyByPage";//获取回复列表

    private static final String DELETE_PROBLEM = "/moli_explore_consumer/problem/v1.1/updateByKeyDeletedSelective";//删除问题

    private static final String MODTIFY_PROBLEM = "/moli_explore_consumer/v1/problem/updateByPrimaryKeySelective";//修改问题

    private static final String PUBLISH_STORY = "/moli_explore_consumer/v1/story/insertSelective ";//发布故事

    private API_Found() {

    }

    public static API_Found ins() {
        if (api == null) {
            synchronized (API_Found.class) {
                if (api == null) {
                    api = new API_Found();
                    switch (RT.HOST) {
                        case DEVELOP:
//                             API_FOUND_SCHEME = "http://192.168.1.20:8010/";
//                            API_FOUND_SCHEME = "http://192.168.1.26:8082/";
                            API_FOUND_SCHEME = "http://192.168.1.28:8084";
                            break;
                        case DEBUG:
                            API_FOUND_SCHEME = "";
                            break;
                        case PUBLISH:
                            API_FOUND_SCHEME = "";
                            break;
                    }
                }
            }
        }
        return api;
    }

    /**
     * 获取文章详情
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494670657131-1722617555-0073
     *
     * @param tag
     * @param callback
     */
    public void getArticleDetailInfo(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ARTICLE_DETAIL_INFO;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("id", id);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取动态详情
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1499678442275-1722617555-0012
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void getDynamicDetailInfo(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_DYNAMIC_DETAIL_INFO;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("id", id);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取问题详情
     *
     * @param tag
     * @param callback
     */
    public void getProblemDetailInfo(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_PROBLEM_DETAIL;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("id", id);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }


    /**
     * 获取问题的回答
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494323107305-1722617555-0022
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void getProblemAnswerInfo(String tag, String id, int pageNum, int pageSize, boolean isSort, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ANSWER_LIST;
        HashMap params = new HashMap();
        params.put("problemId", id);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        if (isSort) {
            params.put("isSort", 1);
        }
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取回答详情
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void getAnswerDetailInfo(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ANSWER_DETAIL;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("id", id);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }


    /**
     * 获取评论列表
     *
     * @param tag
     * @param isSort   获取精彩评论时传1，普通评论为0
     * @param type
     * @param typeId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getCommentList(String tag, int isSort, String type, String typeId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_COMMENT_LIST;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("type", type);
        params.put("isSort", isSort);
        params.put("typeId", typeId);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 发表评论
     *
     * @param tag
     * @param userId
     * @param type
     * @param typeId
     * @param content
     * @param callback
     */
    public void publishComment(String tag, String userId, String type, String typeId, String content, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + ADD_COMMENT;
        HashMap params = new HashMap();
        params.put("userId", userId);
        params.put("type", type);
        params.put("typeId", typeId);
        params.put("content", content);
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 话题详情
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494248034207-1722617555-0007
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void getTopicDetail(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_TOPIC_DEITAL;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("id", id);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 故事详情
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494668303269-1722617555-0067
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void getStoryDetail(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_STORY_DEITAL;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("id", id);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 查看话题的最新问题
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1499843187489-1722617555-0015
     *
     * @param tag
     * @param topicId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getTopicLastProblemList(String tag, String topicId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_NEW_PROBLEM_LIST;
        HashMap params = new HashMap();
        params.put("topicId", topicId);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 查看话题的最热问题
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1499843313998-1722617555-0016
     *
     * @param tag
     * @param topicId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getTopicHotProblemList(String tag, String topicId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_HOT_PROBLEM_LIST;
        HashMap params = new HashMap();
        params.put("isSort", 1);
        params.put("topicId", topicId);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 查看相关话题
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494920860409-1722617555-0003
     *
     * @param tag
     * @param topicIds
     * @param callback
     */
    public void getRelateTopics(String tag, String topicIds, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_RELATE_TOPIC;
        HashMap params = new HashMap();
        params.put("ids", topicIds);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取问题列表
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1496999486873-1722617555-0014
     *
     * @param tag
     * @param isHot    true 问题热门接口 false 最新问题
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getProblemList(String tag, boolean isHot, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_PROBLEM_LIST;
        HashMap params = new HashMap();
        if (isHot) {
            params.put("isHot", 1);
        }
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取问题列表V1.3.0
     * http://doc.java.duailin.top/api/project.do#/ffff-1500554649851-1722617555-0002/front/interface/debug/ffff-1502860544640-1722617555-0017*
     *
     * @param tag
     * @param isHot    true 问题热门接口 false 最新问题
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getNewProblemList(String tag, boolean isHot, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_PROBLEM_DATA_LIST;
        HashMap params = new HashMap();
        if (isHot) {
            params.put("isHot", 1);
        }
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 根据输入内容查问题
     *
     * @param tag
     * @param searchValue
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getProblemListBySearch(String tag, String searchValue, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_PROBLEM_LIST;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("title", searchValue);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 发布问题
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494248904243-1722617555-0010
     *
     * @param tag
     * @param topicIds
     * @param title
     * @param content
     * @param isAnonymous
     * @param callback
     */
    public void publishProblem(String tag, String topicIds, String title, String content, String image, boolean isAnonymous, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + PUBLISH_PROBLEM;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("topicIds", topicIds);
        if (!TextUtils.isEmpty(title))
            params.put("title", title);
        if (!TextUtils.isEmpty(content)) {
            params.put("content", content);
        } else {
            params.put("content", "");
        }
        if (!TextUtils.isEmpty(image)) {
            params.put("image", image);
        }
        params.put("platform", "Android");
        if (isAnonymous) {
            params.put("isAnonymous", 1);
        } else {
            params.put("isAnonymous", 0);
        }
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 回复答案
     *
     * @param tag         problemId
     * @param content
     * @param isAnonymous
     * @param callback
     */
    public void publishAnswer(String tag, String problemId, String content, String headImage, boolean isAnonymous, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + PUBLISH_ANSWER;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("problemId", problemId);
        if (!TextUtils.isEmpty(content))
            params.put("content", content);
        if (!TextUtils.isEmpty(headImage))
            params.put("image", headImage);
        if (isAnonymous) {
            params.put("isAnonymous", 1);
        } else {
            params.put("isAnonymous", 0);
        }
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取文章/动态列表
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interface/debug/ffff-1495176266965-1722617555-0010
     *
     * @param tag
     * @param types
     * @param isHot
     * @param isSort
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getArticleList(String tag, String types, boolean isMine, boolean isHot, boolean isSort, int pageNum, int pageSize, CacheMode mode, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ARTICLE_LIST;
//        String url = "http://192.168.1.17:8086/" + GET_ARTICLE_LIST;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin() && isMine) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("types", types);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        if (isHot) {
            params.put("isHot", 1);
        }
        if (isSort) {
            params.put("isSort", 1);
        }
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, mode, false, callback);
    }

    /**
     * 获取广告列表
     * http://doc.java.duailin.top/api/project.do#/ffff-1494851847113-1722617555-0002/front/interfaceDetail/ffff-1496389014762-1722617555-0014
     *
     * @param tag
     * @param type
     * @param callback
     */
    public void getAdvertisementList(String tag, int type, CacheMode cacheMode, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ADVERTISEMENT_LIST;
        HashMap params = new HashMap();
        params.put("platform", "Android");
        params.put("type", type);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, cacheMode, false, callback);
    }

    /**
     * 获取故事列表
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494669571568-1722617555-0070
     *
     * @param tag
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getStoryList(String tag, int pageNum, int pageSize, CacheMode mode, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_STORY_LIST;
        HashMap params = new HashMap();
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, mode, false, callback);
    }

    /**
     * 获取某人的故事
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494669571568-1722617555-0070
     *
     * @param tag
     * @param userId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getSomeonStoryList(String tag, String userId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_STORY_LIST;
        HashMap params = new HashMap();
        params.put("userId", userId);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取动态列表
     *
     * @param tag
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getSomeoneDynamicList(String tag, String userId, int pageNum, int pageSize, CacheMode mode, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_DYNAMIC_LIST;
        HashMap params = new HashMap();
        params.put("userId", userId);
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("type", AppKey.DYNAMIC_TYPE_SOMEONE);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, mode, false, callback);
    }

    /**
     * 获取动态列表
     *
     * @param tag
     * @param type     0全网动态，1关注的人 2某人
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getDynamicList(String tag, int type, int pageNum, int pageSize, CacheMode mode, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_DYNAMIC_LIST;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("type", type);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, mode, false, callback);
    }

    /**
     * 获取某人的说说
     *
     * @param tag
     * @param pageNum
     * @param pageSize
     * @param mode
     * @param callback
     */
    public void getSomeoneSpeakList(String tag, String userId, int pageNum, int pageSize, CacheMode mode, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_SPEAK_LIST;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("userId", userId);
        params.put("type", AppKey.DYNAMIC_TYPE_SOMEONE);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, mode, false, callback);
    }


    /**
     * 发布动态
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494670208773-1722617555-0072
     *
     * @param tag
     * @param title
     * @param content
     * @param image
     * @param types
     * @param latitude
     * @param longitude
     * @param callback
     */
    public void postDynamic(String tag, String title, String content, String image, String types, String latitude, String longitude, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + POST_DYNAMIC;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        if (!TextUtils.isEmpty(title))
            params.put("title", title);
        if (!TextUtils.isEmpty(content))
            params.put("content", content);
        if (!TextUtils.isEmpty(image))
            params.put("image", image);
        params.put("types", types);
        if (!TextUtils.isEmpty(latitude))
            params.put("latitude", latitude);
        if (!TextUtils.isEmpty(longitude))
            params.put("longitude", longitude);
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 查某人的问题
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/interface/list/ffff-1494240967126-1722617555-0002
     *
     * @param tag
     * @param userId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getSomeOneProblemList(String tag, String userId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_SOMEONE_PROBLEM_LIST;
        HashMap params = new HashMap();
        params.put("userId", userId);
        if (UserManager.ins().isLogin() && UserManager.ins().getUserId().equals(userId)) {

        } else {
            params.put("isAnonymous", 0);
        }
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取某人的文章
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1495176266965-1722617555-0010
     *
     * @param tag
     * @param isSort
     * @param userId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getSomeOneArticleList(String tag, boolean isSort, String userId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ARTICLE_LIST;
        HashMap params = new HashMap();
        params.put("userId", userId);
        if (isSort) {
            params.put("isSort", 1);
        }
        params.put("pageNum", pageNum);
        params.put("types", "publish");
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取某人的回答
     *
     * @param tag
     * @param isSort
     * @param userId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getSomeOneAnswerList(String tag, boolean isSort, String userId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ANSWER_LIST;
        HashMap params = new HashMap();
        params.put("userId", userId);
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        if (isSort) {
            params.put("isSort", 1);
        }
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }


    /**
     * 获取我的回答
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494323107305-1722617555-0022
     *
     * @param tag
     * @param callback
     */
    public void getMyAnswerInfo(String tag, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_ANSWER_LIST;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取我的文章
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1495009447223-1722617555-0005 *
     *
     * @param tag
     * @param callback
     */
    public void getMyArticle(String tag, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_MY_ARTICLE;
        HashMap params = new HashMap();
        params.put("userId", UserManager.ins().getUserId());
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取我的提问
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494339062557-1722617555-0025
     *
     * @param tag
     * @param callback
     */
    public void getMyProblem(String tag, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_PROBLEM_LIST;
        HashMap params = new HashMap();
        params.put("userId", UserManager.ins().getUserId());
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取推荐话题
     * http://doc.java.duailin.top/api/index.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494331119130-1722617555-0024
     *
     * @param tag
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getRecommandTopic(String tag, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_RECOMMAND_TOPIC;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取提问时的推荐话题
     * http://doc.java.duailin.top/api/index.do#/ffff-1500554649851-1722617555-0002/front/interfaceDetail/ffff-1502954050256-1722617555-0021
     *
     * @param tag
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getRecommandTopicForAskQuestion(String tag, String topicName, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_RECOMMAND_TOPIC_FOR_ASK_QUESTION;
        HashMap params = new HashMap();
        if (!TextUtils.isEmpty(topicName)) {
            params.put("topicName", topicName);
        }
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }


    /**
     * 删除我的回答
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494311864410-1722617555-0016
     *
     * @param tag
     * @param id
     * @param problemId
     * @param callback
     */
    public void deleteMyAnswer(String tag, String id, String problemId, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + DELETE_ANSWER;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("id", id);
        params.put("problemId", problemId);
        params.put("deleted", 1);
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 修改回答
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494247042434-1722617555-0004
     *
     * @param tag
     * @param id
     * @param problemId
     * @param callback
     */
    public void modtifyAnswer(String tag, String id, String problemId, String content, String image, boolean isAnonymous, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + MODTIFY_ANSWER;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("id", id);
        params.put("problemId", problemId);
        params.put("content", content);
        if (!TextUtils.isEmpty(image)) {
            params.put("image", image);
        }
        if (isAnonymous) {
            params.put("isAnonymous", 1);
        } else {
            params.put("isAnonymous", 0);
        }
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }


    /**
     * 删除我的发表
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494671025517-1722617555-0075
     *
     * @param tag
     * @param id
     * @param type
     * @param callback
     */
    public void deleteMyPublish(String tag, String id, String type, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + DELETE_PUBLISH;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("id", id);
        params.put("types", type);
        params.put("deleted", 1);
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 删除我的故事
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494668801657-1722617555-0069
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void deleteMyStory(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + DELETE_STORY;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("id", id);
        params.put("deleted", 1);
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取评论详情
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494306911489-1722617555-0015
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void getCommentDetail(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_COMMENT_DETAIL;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        params.put("id", id);
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取官方推送
     *
     * @param tag
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getOffiaiaPush(String tag, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_OFFIAIA_PUSH;
        HashMap params = new HashMap();
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取下一个回答
     *
     * @param tag
     * @param id
     * @param problemId
     * @param isSort
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getNextAnswer(String tag, String id, String problemId, boolean isSort, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_NEXT_ANSWER;
        HashMap params = new HashMap();
        params.put("pageNum", pageNum);
        params.put("id", id);
        params.put("pageSize", pageSize);
        params.put("problemId", problemId);
        if (isSort) {
            params.put("isSort", 1);
        }
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 获取评论的回复列表
     * http://doc.java.duailin.top/api/project.do#/ffff-1500554649851-1722617555-0002/front/interfaceDetail/ffff-1500555275506-1722617555-0004
     *
     * @param tag
     * @param commentId
     * @param pageNum
     * @param pageSize
     * @param callback
     */
    public void getReplyCommentList(String tag, String commentId, int pageNum, int pageSize, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + GET_REPLY_COMMENT;
        HashMap params = new HashMap();
        params.put("commentId", commentId);
        params.put("pageNum", pageNum);
        params.put("pageSize", pageSize);
        if (UserManager.ins().isLogin()) {
            params.put("uid", UserManager.ins().getUserId());
        }
        NetworkInterface.ins().connected(HttpMethod.GET, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 添加评论的回复
     * http://doc.java.duailin.top/api/project.do#/ffff-1500554649851-1722617555-0002/front/interfaceDetail/ffff-1500554825533-1722617555-0002
     *
     * @param tag
     * @param commentId
     * @param replyUserId
     * @param replyUserName
     * @param content
     * @param callback
     */
    public void addCommentReply(String tag, String commentId, String replyUserId, String replyUserName, String content, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + ADD_REPLY;
        HashMap params = new HashMap();
        params.put("commentId", commentId);
        params.put("replyUserId", replyUserId);
        params.put("replyUserName", replyUserName);
        params.put("content", content);
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
            params.put("userName", UserManager.ins().getLoginUser().getName());
            params.put("userImage", UserManager.ins().getLoginUser().getImage());
        }
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 删除评论的回复
     * http://doc.java.duailin.top/api/project.do#/ffff-1500554649851-1722617555-0002/front/interfaceDetail/ffff-1500555024909-1722617555-0003
     *
     * @param tag
     * @param replyId
     * @param callback
     */
    public void deleteCommentReply(String tag, String replyId, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + DELETE_REPLY;
        HashMap params = new HashMap();
        params.put("id", replyId);
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * http://doc.java.duailin.top/api/project.do#/ffff-1500554649851-1722617555-0002/front/interfaceDetail/ffff-1501485338290-1722617555-0009
     * 删除问题
     *
     * @param tag
     * @param id
     * @param callback
     */
    public void deleteProblem(String tag, String id, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + DELETE_PROBLEM;
        HashMap params = new HashMap();
        params.put("id", id);
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 修改问题
     * http://doc.java.duailin.top/api/project.do#/ffff-1500554649851-1722617555-0002/front/interfaceDetail/ffff-1501485338291-1722617555-0010
     *
     * @param tag
     * @param id
     * @param topicIds
     * @param title
     * @param content
     * @param image
     * @param isAnonymous
     */
    public void modtifyProblem(String tag, String id, String topicIds, String title, String content, String image, int isAnonymous, ResponseCallback callback) {
        String url = API_FOUND_SCHEME + MODTIFY_PROBLEM;
        HashMap params = new HashMap();
        params.put("id", id);
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("topicIds", topicIds);
        params.put("title", title);
        if (!TextUtils.isEmpty(content)) {
            params.put("content", content);
        } else {
            params.put("content", "");
        }
        if (!TextUtils.isEmpty(image)) {
            params.put("image", image);
        }
        params.put("platform", "Android");
        params.put("isAnonymous", isAnonymous);
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

    /**
     * 发布故事
     * http://doc.java.duailin.top/api/project.do#/ffff-1494211670703-1722617555-0002/front/interfaceDetail/ffff-1494668575254-1722617555-0068
     * @param tag
     * @param title
     * @param content
     * @param image
     * @param audioUrl
     * @param time
     * @param callback
     */
    public void publishStory(String tag, String title, String content, String image, String audioUrl, String time, String albumId,ResponseCallback callback) {
        String url = API_FOUND_SCHEME + PUBLISH_STORY;
        HashMap params = new HashMap();
        if (UserManager.ins().isLogin()) {
            params.put("userId", UserManager.ins().getUserId());
        }
        params.put("title", title);
        if (!TextUtils.isEmpty(content)) {
            params.put("content", content);
        }
        if (!TextUtils.isEmpty(albumId)) {
            params.put("albumId", albumId);
        }
        params.put("image", image);
        params.put("audioUrl", audioUrl);
        params.put("platform", "Android");
        params.put("time", time);
        NetworkInterface.ins().connected(HttpMethod.POST, url, tag, params, CacheMode.DEFAULT, false, callback);
    }

}
